﻿/* Write a program that reads a year from the console and checks whether it is a leap. 
 * Use DateTime. */
using System;

namespace _1.CheckIfLeap
{
    class CheckIfLeap
    {
        static void Main()
        {
            int y;
            bool iProvided = false;

            do
            {
                if (iProvided == true) Console.WriteLine("Error: Invalid year entered. Please enter a valid year between 1 and 9999");
                else iProvided = true;
                Console.Write("Please enter a year: ");

            } while (Int32.TryParse(Console.ReadLine(), out y) == false || y < 1 || y > 9999);
            //check if we have a leap year
            bool leap_y = DateTime.IsLeapYear(y);
            string leap_y_str = null;
            if (leap_y) leap_y_str = "is leap";
            else leap_y_str = "is not leap";
            Console.WriteLine("Year {0} {1}", y, leap_y_str);
        }
    }
}
